<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>17.自由变量</title>
</head>

<body>

  <script>
    let i
    for (i = 1; i <= 3; i++) {
      setTimeout(function () {
        console.log(i);
      }, 0)
    }


    let a = 10
    function test() {
      alert(a) // 10
      a = 100
      alert(a) // 100
    }
    test()
    alert(a) // 100


  </script>

</body>

</html>